package com.llsydn.demo.selectContact;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.EditText;
import com.llsydn.hello.R;

public class SelectContactActivity extends AppCompatActivity {

    private EditText et_main_number;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_select_contact);
        et_main_number = findViewById(R.id.et_main_number);
    }

    /**
     * 选择联系人
     *
     * @param view
     */
    public void selectContact(View view) {
        //启动联系人列表界面
        Intent intent = new Intent(this, ContactListActivity.class);
        startActivityForResult(intent, 1);
    }

    /**
     * 带结果的回调
     *
     * @param requestCode
     * @param resultCode
     * @param data
     */
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == 1 && resultCode == RESULT_OK) {
            //得到返回的number
            String number = data.getStringExtra("NUMBER");
            et_main_number.setText(number);
        }
        super.onActivityResult(requestCode, resultCode, data);
    }
}
